<%@ page language="java" import="java.util.*" pageEncoding="utf-8"%>
<%@ taglib uri="http://java.sun.com/jsp/jstl/core" prefix="c" %>
<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN">
<html>
  <head>
    <title>已收邮件</title>
    <script language="JavaScript" src="${pageContext.request.contextPath}/luhong/mydate.js"></script>
   	<script type="text/javascript" src="${pageContext.request.contextPath }/js/jquery.js"></script>
    <script type="text/javascript">
    	//清空时间
    	function freeTime(){
    		document.getElementById("starttime").value="";
    		document.getElementById("endtime").value="";
    	}
    	function skipPage(currentPage){
        	var url='${pageContext.request.contextPath }/receiveEmail.action?method=queryReceiveEmail&currPage='+currentPage;
        	window.location.href=url;
      	}
      	function read(id,status){
      		//${num}="";
      		if(status=='1'){
      			return;
      		}else{
      			var url='${pageContext.request.contextPath }/receiveEmail.action?method=queryRecReadEmail&eid='+id;
        		window.location.href=url;
      		}
      		var url='${pageContext.request.contextPath }/receiveEmail.action?method=queryRecReadEmail&eid='+id;
        	window.location.href=url;
     		//if($('#id_status').text().trim()=="已读"){
     		//	alert(2221);
     		//	var url = '${pageContext.request.contextPath}/projectManage.action?method=mailNum';
     		//	window.location.href=url;
     		//}
      	}
      	function del(id){
      		if(confirm("您确定要删除吗？")){
      			var url='${pageContext.request.contextPath }/receiveEmail.action?method=delReciveEmail&eid='+id;
        		window.location.href=url;
        	}
      	}
      	function query(){
      		var id=document.getElementById("sid").value;
    		var stime=document.getElementById("starttime").value;
    		var etime=document.getElementById("endtime").value;
    		var etype=document.getElementById("etype").value;
    		var url='${pageContext.request.contextPath }/receiveEmail.action?method=queryReceiveEmail&sid='+id+'&stime='+stime+'&etime='+etime+'&etype='+etype;
        	window.location.href=url;
      	}
      	function checkType(){
      		var readType='${requestScope.readType}';
      		if(readType!=null&&readType!=""){
      			(document.getElementById("etype").value=readType).checked;
      		}
      	}
      	var oldColor;
		function choice(trObj) {
			oldColor = trObj.bgColor;
			trObj.bgColor = "yellow";
		}
		function leave(trObj) {
			trObj.bgColor = oldColor;
		}
    </script>
     <style type="text/css">
    		a{
    			cursor:pointer;
    		}
    		body {
				background-image:
				url(${pageContext.request.contextPath}/images/forum7.jpg);
			}
			td{
				font-size:14px;
			}
    </style>
  </head>
  
  <body onload="checkType();">
   <center><strong>收件箱</strong></center>
   <div style="background-color:skyblue;">
   	 发件人姓名:<input type="text" name="sid" id="sid" value="${requestScope.acRecipientid}"/>
  	写件时间：
  	<input type="text" name="starttime" id="starttime" onfocus="MyCalendar.SetDate(this)" value="${requestScope.sactime }" readonly>
   	--<input type="text" name="endtime" id="endtime" onfocus="MyCalendar.SetDate(this)" value="${requestScope.eactime }" readonly>
   	<input type="button" value="清空时间" onclick="freeTime();">
	<select id="etype">
		<option value="1">
			全部邮件
		</option>
		<option value="2">
			已读邮件
		</option>
		<option value="3">
			未读邮件
		</option>
	</select>
	<input type="button" value="查找" onclick="query();">
   </div>
   <br/>
   <div style="height:320px;">
   <table align="center" border="1px" cellspacing="0px" cellpadding="0px">
   	<tr>
   		<td>发件人</td>
   		<td>Email主题</td>
   		<td>邮件附录地址1</td>
   		<td>邮件附录地址2</td>
   		<td>邮件附录地址3</td>
   		<td>邮件正文</td>
   		<td>发件时间</td>
   		<td>读取状态</td>
   		<td>编辑</td>
   	</tr>
   	<tr>
   			<c:forEach items="${requestScope.receivepage.maildata}" var="view" varStatus="c">
   	 		<tr bgcolor="${c.index%2==0?'white':'skyblue'}"  onmouseover=choice(this); onmouseout=leave(this);>
   	 			<td>${view.addresserName }(${view.addresserId })</td>
   	 			<td>${view.emailTopic }</td>
   	 			<td><a href="${pageContext.request.contextPath}/file/EmailFile/${view.emailFile1Add}">${view.emailFile1}</a></td>
   	 			<td><a href="${pageContext.request.contextPath}/file/EmailFile/${view.emailFile2Add}">${view.emailFile2}</a></td>
   	 			<td><a href="${pageContext.request.contextPath}/file/EmailFile/${view.emailFile3Add}">${view.emailFile3}</a></td>
   	 			<td>${view.emailText }</td>
   	 			<td>${view.emailDate }</td>
   	 			<td id="id_status">
   	 				<c:if test="${view.emailReadStatus=='0'}">
   	 					<font color='red'><strong>未读</strong></font>
   	 				</c:if>
   	 				<c:if test="${view.emailReadStatus=='1'}">
   	 					已读
   	 				</c:if>	
   	 			</td>
   	 			
   	 			<td><a onclick="read('${view.emailId }','${view.emailReadStatus}');">读取</a>&nbsp;<a onclick="del('${view.emailId }');">删除</a></td>
   	 		</tr>
   	 	</c:forEach>
   	</tr>
   </table>
   </div>
   <table align="center">
			<tr>
				<td>
					<a onclick="skipPage('1')";>首页</a>
				</td>
				<td>
					<a
						onclick="skipPage('${requestScope.receivepage.currentPage==1?1:requestScope.receivepage.currentPage-1 }');">上一页</a>
				</td>
				<td>
					<a
						onclick="skipPage('${requestScope.receivepage.currentPage==requestScope.receivepage.totalPage?(requestScope.receivepage.currentPage):(requestScope.receivepage.currentPage+1) }');">下一页</a>
				</td>
				<td>
					<a onclick="skipPage('${requestScope.receivepage.totalPage}');">末页</a>
				</td>
				<td>
					当前页码：${requestScope.receivepage.currentPage}/${requestScope.receivepage.totalPage}
				</td>
			</tr>
		</table>
  </body>
</html>
